package com.hbnu.personaldiaryweb.service;

import com.hbnu.personaldiaryweb.entity.Diary;
import com.hbnu.personaldiaryweb.mapper.DiaryMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DiaryService implements DiaryMapper {

    //定义一个自动装配
    @Autowired
    DiaryMapper diaryMapper;


    @Override
    public int insertDiary(Diary diary) {
        return this.diaryMapper.insertDiary(diary);
    }

    @Override
    public Diary getDiaryById(String id) {
        return this.diaryMapper.getDiaryById(id);
    }



    @Override
    public List<Diary> getAllDiaries() {
        return this.diaryMapper.getAllDiaries();
    }

    @Override
    public int updateDiary(Diary diary) {
        return this.diaryMapper.updateDiary(diary);
    }

    @Override
    public int deleteDiaryById(String id) {
        return this.diaryMapper.deleteDiaryById(id);
    }

    @Override
    public List<Diary> getDiariesByUserId(String user_id) {
        return this.diaryMapper.getDiariesByUserId(user_id);
    }

    @Override
    public List<Diary> getDiariesAllByUserAndLabel(String user_id, String label) {
        return this.diaryMapper.getDiariesAllByUserAndLabel(user_id,label);
    }

    @Override
    public List<Diary> getDiariesMiniByUserAndLabel(String user_id, String label) {
        return this.diaryMapper.getDiariesMiniByUserAndLabel(user_id, label);
    }

    @Override
    public List<String> getLabelsByUser(String user_id) {
        System.out.println(this.diaryMapper.getLabelsByUser(user_id));

        return this.diaryMapper.getLabelsByUser(user_id);
    }
}
